--temp为数据库名,temp_log为数据库日志名,收缩前备份数据库

DBCC SHRINKDATABASE('temp')
 
alter database temp set recovery simple
go
dbcc shrinkfile('temp_log',0,truncateonly)
go
alter database temp set recovery full

--更新数据,非必需
DBCC UPDATEUSAGE (0)


--第二种方法收缩日志文件
USE[master]
GO
ALTER DATABASE t1 SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE t1 SET RECOVERY SIMPLE   --简单模式
GO
USE t1
GO
DBCC SHRINKFILE (N't1_Log' , 11, TRUNCATEONLY)
GO
USE[master]
GO
ALTER DATABASE t1 SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE t1 SET RECOVERY FULL  --还原为完全模式

GO